package com.hotcomm.test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class HelloWorld {
    public static void main(String []args) throws Exception {
        final String url="jdbc:postgresql://192.168.123.141:5432/hotcomm_v1";
        final String user="postgres";
        final String password = "137121";
        Class.forName("org.postgresql.Driver");
        String sql="select *  from hk_data";
        try(Connection connection = DriverManager.getConnection(url, user, password); ){
            System.out.println("是否成功连接pg数据库"+connection);
            try(Statement statement=connection.createStatement();){
            	  ResultSet resultSet=statement.executeQuery(sql);
                  while(resultSet.next()){
                      String name=resultSet.getString(1);
                      System.out.println(name);
                  }
            }catch(Exception e){
                throw new RuntimeException(e);
            }
        }catch(Exception e){
            throw new RuntimeException(e);
        }
    }
    
    
    
    
}